#include "const.h"

void v_cat(var_t v, const char *value) {
	size_t l, n;

	if (v->flags & VAR_CONST_BIT)
		return;

	if (v->flags & VAR_SYMLINK_BIT) {
		v_cat(v->value.symlink, value);
		return;
	}

	if (v->flags & VAR_ARRAY_BIT) {
		v_array_push(v, value);
		return;
	}

	l = strlen(v->value.text);
	n = strlen(value) + 1;

	v->value.text = (char *)i_renew((void *)v->value.text, l + n);
	memcpy(&v->value.text[l], (const void *)value, n);

	if (v->expanded) {
		i_delete((void *)v->expanded);
		v->expanded = (char *)0;
	}
}
